local wusheng = fk.CreateSkill{
    name = "lingling__wusheng",
}
Fk:loadTranslationTable{
    ["lingling__wusheng"] = "武圣",
    [":lingling__wusheng"] = "回合开始时，你可以指定一名其他角色，其摸一张牌，本回合你与其距离视为1，且你前三次对其使用一张牌时，其需交给你一张牌或受到你造成的1点伤害。",
    ["@@lingling__wusheng-turn"] = "被武圣",
    ["#lingling__wusheng-choose"] = "是否发动 武圣，令一名其他角色摸一张牌，本回合你与其距离视为1，且对其使用牌时有额外收益",
    ["#lingling__wusheng-card"] = "武圣：交给 %dest 一张牌，或受到其造成的1点伤害",

    ["$lingling__wusheng1"] = "千军斩将而回，于某又有何难？",
    ["$lingling__wusheng2"] = "对敌岂遵一招一式！",
    ["$lingling__wusheng3"] = "关某既出，敌将定皆披靡。",
}
wusheng:addEffect(fk.TurnStart,{
    anim_type = "offensive",
    can_trigger = function (self, event, target, player, data)
        return target == player and player:hasSkill(wusheng.name) and
        #player.room:getOtherPlayers(player, false) > 0
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local to = room:askToChoosePlayers(player, {
            min_num = 1,
            max_num = 1,
            targets = room:getOtherPlayers(player, false),
            skill_name = wusheng.name,
            prompt = "#lingling__wusheng-choose",
            cancelable = true,
        })
        if #to > 0 then
            event:setCostData(self, {tos = to})
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local to = event:getCostData(self).tos[1]
        room:doSuperLightBox("packages/lingling/qml/mouguanyu.qml")
        room:delay(2500)
        room:setPlayerMark(to, "@@lingling__wusheng-turn", 1)
        room:addTableMark(player, "lingling__wusheng-turn", to.id)
        to:drawCards(1,wusheng.name)
    end,
})
wusheng:addEffect(fk.TargetSpecified, {
    mute = true,
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        if target == player and data.to:isAlive() and
        table.contains(player:getTableMark("lingling__wusheng-turn"),data.to.id) then
            return data.to:getMark("lingling__wusheng_used-turn") < 3
        end
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local to = data.to
        room:doAnimate("InvokeSkill", {
            name = wusheng.name,
            player = player.id,
            skill_type = "offensive",
        })
        room:addPlayerMark(data.to,"lingling__wusheng_used-turn",1)
        player:broadcastSkillInvoke(wusheng.name,-1)
        local card = room:askToCards(to, {
            min_num = 1,
            max_num = 1,
            skill_name = wusheng.name,
            include_equip = true,
            cancelable = true,
            prompt = "#lingling__wusheng-card::"..player.id,
        })
        event:setCostData(self,{cards = card})
        return true
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local to = data.to
        local cards = event:getCostData(self).cards
        if #cards > 0 then
            room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonGive, wusheng.name, nil, false, to)
        else
            room:damage{
                from = player,
                to = to,
                damage = 1,
                skillName = wusheng.name,
            }
        end
    end,
})
wusheng:addEffect("distance", {
    name = "#fenxun_distance",
    fixed_func = function(self, from, to)
        if table.contains(from:getTableMark("lingling__wusheng-turn"), to.id) then
            return 1
        end
    end,
})
wusheng:addEffect(fk.GameStart, {
    priority = 2,
    mute = true,
    is_delay_effect = true,
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(wusheng.name,true) and player.general == "lingling__guanyu" and
        table.find(player.room.alive_players, function (p)
            return p.general == "lingling__qinqiong"
        end)
    end,
    on_trigger = function (self, event, target, player, data)
        local room = player.room
        local qinqiong = table.find(room.alive_players, function (p)
        return p.general == "lingling__qinqiong"
        end)
        room:sendLog{
        type = "#lingling__qingqiong_EasterEgg",
        from = player.id,
        toast = true,
        }
        local card = room:getCardsFromPileByRule("slash")
        if #card > 0 then
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonJustMove)
        end
        if qinqiong and not qinqiong.dead then
        card = room:getCardsFromPileByRule("slash")
        if #card > 0 then
            room:moveCardTo(card, Card.PlayerHand, qinqiong, fk.ReasonJustMove)
        end
        end
    end,
})
return wusheng